﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;

namespace System.Data.SharePoint
{
    public class SharePointCommand : DbCommand
    {
        public SharePointCommand()
        {

        }

        public SharePointCommand(string commandText)
        {
            this._commandText = commandText;
        }

        public SharePointCommand(string commandText, SharePointConnection connection) : this(commandText)
        {
            this.Connection = connection;
        }

        public override void Cancel()
        {
            throw new NotImplementedException();
        }

        private string _commandText;
        public override string CommandText
        {
            get
            {
                return this._commandText;
            }
            set
            {
                this._commandText = value;
            }
        }

        public override int CommandTimeout
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        private CommandType _commandType = CommandType.Text;
        public override CommandType CommandType
        {
            get
            {
                return this._commandType;
            }
            set
            {
                this._commandType = value;
            }
        }

        protected override DbParameter CreateDbParameter()
        {
            // TODO: sharepoint parameter.
            return new SharePointParameter();
        }

        private DbConnection _dbConnection;
        protected override DbConnection DbConnection
        {
            get
            {
                return this._dbConnection;
            }
            set
            {
                this._dbConnection = value;
            }
        }

        public new SharePointConnection Connection
        {
            get
            {
                return (SharePointConnection)this.DbConnection;
            }
            set
            {
                this.DbConnection = value;
            }
        }

        protected override DbParameterCollection DbParameterCollection
        {
            get { return new SharePointParameterCollection(); }
        }
                
        protected override DbTransaction DbTransaction
        {
            get
            {
                return null;
            }
            set
            {
                
            }
        }

        public override bool DesignTimeVisible
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
        {
            return new SharePointDataReader(this);
        }

        public override int ExecuteNonQuery()
        {
            throw new NotImplementedException();
        }

        public override object ExecuteScalar()
        {
            throw new NotImplementedException();
        }

        public override void Prepare()
        {
            throw new NotImplementedException();
        }

        public override UpdateRowSource UpdatedRowSource
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }


        public string ListUrl
        {
            get;
            set;
        }

        public string ViewFields
        {
            get;
            set;
        }
    }
}
